package com.ssy.lingxi.product.common.enums;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;
import java.util.Objects;

/**
 * 物料流程适用类型枚举类型义
 * @author pengdd
 * @version 2.0.0
 * @date 2022/3/24
 */
public enum MaterialProcessTypeEnum {
    ADD(1, "新增物料流程"),
    CHANGE_OR_ENABLE(2, "变更/启用物料流程"),
    ;
    private final Integer code;
    private final String message;
    MaterialProcessTypeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return this.code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getDeclaringClass(), this.getCode());
    }

    public static String getMessage(Integer code) {
        return Arrays.stream(MaterialProcessTypeEnum.values()).filter(f -> Objects.equals(f.getCode(), code)).findFirst().map(MaterialProcessTypeEnum::getMessage).orElse("");
    }
}
